/**
 * 
 */
package br.com.ctm.guiamedico.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

import br.com.framework.persistencia.model.AuditedEntity;

/**
 * @author Cleber
 * 
 */
@Entity
@Table(name = "HOSPITAL")
@XmlRootElement
public class Hospital extends AuditedEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String nome;
	
	private List<Endereco> enderecos;

	/**
	 * 
	 */
	public Hospital() {
	}
	
	@Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="SEQ_ESPECIALIDADE")
	@SequenceGenerator(name="SEQ_ESPECIALIDADE", sequenceName="SEQ_ESPECIALIDADE", allocationSize=1, initialValue=0)
	@Column(name = "ID_ESPECIALIDADE")
	public Long getId() {
		return super.getId();
	}

	/**
	 * @return the nome
	 */
	@Column(name = "NOME", length = 255, nullable = false)
	@Size(min = 1, max = 255, message = "{geral.campo.tamanhoInvalido}")
	public String getNome() {
		return nome;
	}

	/**
	 * @param nome
	 *            the nome to set
	 */
	public void setNome(String titulo) {
		this.nome = titulo;
	}

	/**
	 * @return the enderecos
	 */
	@ManyToMany(targetEntity = Endereco.class)
	@JoinTable(name = "HOSPITAL_ENDERECO", 
		joinColumns = @JoinColumn(name = "ID_HOSPITAL", referencedColumnName = "ID_HOSPITAL"), 
		inverseJoinColumns = @JoinColumn(name = "ID_ENDERECO", referencedColumnName = "ID_ENDERECO"))
	@Size(min = 1, message = "{hospital.enderecos.tamanhoInvalido}")
	public List<Endereco> getEnderecos() {
		return enderecos;
	}

	/**
	 * @param enderecos the enderecos to set
	 */
	public void setEnderecos(List<Endereco> enderecos) {
		this.enderecos = enderecos;
	}

	
}
